using DAO;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Easislides
{
	public class FrmFind : Form
	{
		private const int WordListMax = 20;
		private IContainer components = null;
		private TabControl TabControl1;
		private TabPage tabPage1;
		private TabPage tabPage2;
		private Button BtnCancel;
		private Button BtnOK;
		private CheckedListBox FolderList;
		private TextBox txtName;
		private Label label1;
		private GroupBox groupBox2;
		private GroupBox groupBox1;
		private TextBox PassageSearchBox;
		private Label label2;
		private ComboBox BibleLookup;
		private Label label3;
		private Label label4;
		private ComboBox BookLookup;
		private RadioButton MatchPhrase;
		private RadioButton MatchAny;
		private RadioButton MatchAll;
		private ComboBox SongKey;
		private CheckBox cbLicAdmin;
		private CheckBox cbUserRef;
		private CheckBox cbBookRef;
		private CheckBox cbSongNumber;
		private CheckBox cbContents;
		private CheckBox cbTitle;
		private CheckBox cbCopyright;
		private CheckBox cbWriter;
		private CheckBox cbNotationsOnly;
		private CheckBox cbMusicOnly;
		private Label label5;
		private Timer TimerRestoreWindow;
		private DateTimePicker CalendarTo;
		private DateTimePicker CalendarFrom;
		private CheckBox cbUseDates;
		private Label label6;
		private Label label7;
		private ComboBox SongTiming;
		private bool InitFormLoad = true;
		private string[] WordList = new string[20];
		private string Reg_FormLeft = "SearchFormLeft";
		private string Reg_FormTop = "SearchFormTop";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.TabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.CalendarTo = new System.Windows.Forms.DateTimePicker();
            this.CalendarFrom = new System.Windows.Forms.DateTimePicker();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.SongTiming = new System.Windows.Forms.ComboBox();
            this.label7 = new System.Windows.Forms.Label();
            this.cbNotationsOnly = new System.Windows.Forms.CheckBox();
            this.cbMusicOnly = new System.Windows.Forms.CheckBox();
            this.SongKey = new System.Windows.Forms.ComboBox();
            this.label5 = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.cbCopyright = new System.Windows.Forms.CheckBox();
            this.cbWriter = new System.Windows.Forms.CheckBox();
            this.cbLicAdmin = new System.Windows.Forms.CheckBox();
            this.cbUserRef = new System.Windows.Forms.CheckBox();
            this.cbBookRef = new System.Windows.Forms.CheckBox();
            this.cbSongNumber = new System.Windows.Forms.CheckBox();
            this.cbContents = new System.Windows.Forms.CheckBox();
            this.cbTitle = new System.Windows.Forms.CheckBox();
            this.FolderList = new System.Windows.Forms.CheckedListBox();
            this.txtName = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.cbUseDates = new System.Windows.Forms.CheckBox();
            this.label6 = new System.Windows.Forms.Label();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.MatchPhrase = new System.Windows.Forms.RadioButton();
            this.MatchAny = new System.Windows.Forms.RadioButton();
            this.MatchAll = new System.Windows.Forms.RadioButton();
            this.BookLookup = new System.Windows.Forms.ComboBox();
            this.BibleLookup = new System.Windows.Forms.ComboBox();
            this.PassageSearchBox = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.BtnCancel = new System.Windows.Forms.Button();
            this.BtnOK = new System.Windows.Forms.Button();
            this.TimerRestoreWindow = new System.Windows.Forms.Timer(this.components);
            this.TabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.SuspendLayout();
            // 
            // TabControl1
            // 
            this.TabControl1.Controls.Add(this.tabPage1);
            this.TabControl1.Controls.Add(this.tabPage2);
            this.TabControl1.Location = new System.Drawing.Point(12, 12);
            this.TabControl1.Name = "TabControl1";
            this.TabControl1.SelectedIndex = 0;
            this.TabControl1.Size = new System.Drawing.Size(390, 256);
            this.TabControl1.TabIndex = 0;
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.CalendarTo);
            this.tabPage1.Controls.Add(this.CalendarFrom);
            this.tabPage1.Controls.Add(this.groupBox2);
            this.tabPage1.Controls.Add(this.groupBox1);
            this.tabPage1.Controls.Add(this.FolderList);
            this.tabPage1.Controls.Add(this.txtName);
            this.tabPage1.Controls.Add(this.label1);
            this.tabPage1.Controls.Add(this.cbUseDates);
            this.tabPage1.Controls.Add(this.label6);
            this.tabPage1.Location = new System.Drawing.Point(4, 22);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage1.Size = new System.Drawing.Size(382, 230);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "Folder Search";
            // 
            // CalendarTo
            // 
            this.CalendarTo.Location = new System.Drawing.Point(222, 201);
            this.CalendarTo.Name = "CalendarTo";
            this.CalendarTo.Size = new System.Drawing.Size(154, 20);
            this.CalendarTo.TabIndex = 7;
            // 
            // CalendarFrom
            // 
            this.CalendarFrom.Location = new System.Drawing.Point(221, 166);
            this.CalendarFrom.Name = "CalendarFrom";
            this.CalendarFrom.Size = new System.Drawing.Size(155, 20);
            this.CalendarFrom.TabIndex = 5;
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.SongTiming);
            this.groupBox2.Controls.Add(this.label7);
            this.groupBox2.Controls.Add(this.cbNotationsOnly);
            this.groupBox2.Controls.Add(this.cbMusicOnly);
            this.groupBox2.Controls.Add(this.SongKey);
            this.groupBox2.Controls.Add(this.label5);
            this.groupBox2.Location = new System.Drawing.Point(221, 49);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(155, 96);
            this.groupBox2.TabIndex = 3;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Restrict To";
            // 
            // SongTiming
            // 
            this.SongTiming.FormattingEnabled = true;
            this.SongTiming.Location = new System.Drawing.Point(52, 73);
            this.SongTiming.Name = "SongTiming";
            this.SongTiming.Size = new System.Drawing.Size(71, 21);
            this.SongTiming.TabIndex = 10;
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(6, 76);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(41, 13);
            this.label7.TabIndex = 9;
            this.label7.Text = "Timing:";
            // 
            // cbNotationsOnly
            // 
            this.cbNotationsOnly.AutoSize = true;
            this.cbNotationsOnly.Location = new System.Drawing.Point(8, 34);
            this.cbNotationsOnly.Name = "cbNotationsOnly";
            this.cbNotationsOnly.Size = new System.Drawing.Size(96, 17);
            this.cbNotationsOnly.TabIndex = 1;
            this.cbNotationsOnly.Text = "With Notations";
            // 
            // cbMusicOnly
            // 
            this.cbMusicOnly.AutoSize = true;
            this.cbMusicOnly.Location = new System.Drawing.Point(8, 17);
            this.cbMusicOnly.Name = "cbMusicOnly";
            this.cbMusicOnly.Size = new System.Drawing.Size(98, 17);
            this.cbMusicOnly.TabIndex = 0;
            this.cbMusicOnly.Text = "With Music File";
            // 
            // SongKey
            // 
            this.SongKey.FormattingEnabled = true;
            this.SongKey.Location = new System.Drawing.Point(52, 52);
            this.SongKey.Name = "SongKey";
            this.SongKey.Size = new System.Drawing.Size(71, 21);
            this.SongKey.TabIndex = 3;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(6, 54);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(28, 13);
            this.label5.TabIndex = 2;
            this.label5.Text = "Key:";
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.cbCopyright);
            this.groupBox1.Controls.Add(this.cbWriter);
            this.groupBox1.Controls.Add(this.cbLicAdmin);
            this.groupBox1.Controls.Add(this.cbUserRef);
            this.groupBox1.Controls.Add(this.cbBookRef);
            this.groupBox1.Controls.Add(this.cbSongNumber);
            this.groupBox1.Controls.Add(this.cbContents);
            this.groupBox1.Controls.Add(this.cbTitle);
            this.groupBox1.Location = new System.Drawing.Point(125, 49);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(90, 174);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Search On";
            // 
            // cbCopyright
            // 
            this.cbCopyright.AutoSize = true;
            this.cbCopyright.Location = new System.Drawing.Point(8, 84);
            this.cbCopyright.Name = "cbCopyright";
            this.cbCopyright.Size = new System.Drawing.Size(70, 17);
            this.cbCopyright.TabIndex = 4;
            this.cbCopyright.Text = "Copyright";
            // 
            // cbWriter
            // 
            this.cbWriter.AutoSize = true;
            this.cbWriter.Location = new System.Drawing.Point(8, 67);
            this.cbWriter.Name = "cbWriter";
            this.cbWriter.Size = new System.Drawing.Size(54, 17);
            this.cbWriter.TabIndex = 3;
            this.cbWriter.Text = "Writer";
            // 
            // cbLicAdmin
            // 
            this.cbLicAdmin.AutoSize = true;
            this.cbLicAdmin.Location = new System.Drawing.Point(8, 134);
            this.cbLicAdmin.Name = "cbLicAdmin";
            this.cbLicAdmin.Size = new System.Drawing.Size(72, 17);
            this.cbLicAdmin.TabIndex = 7;
            this.cbLicAdmin.Text = "Lic Admin";
            // 
            // cbUserRef
            // 
            this.cbUserRef.AutoSize = true;
            this.cbUserRef.Location = new System.Drawing.Point(8, 117);
            this.cbUserRef.Name = "cbUserRef";
            this.cbUserRef.Size = new System.Drawing.Size(68, 17);
            this.cbUserRef.TabIndex = 6;
            this.cbUserRef.Text = "User Ref";
            // 
            // cbBookRef
            // 
            this.cbBookRef.AutoSize = true;
            this.cbBookRef.Location = new System.Drawing.Point(8, 100);
            this.cbBookRef.Name = "cbBookRef";
            this.cbBookRef.Size = new System.Drawing.Size(71, 17);
            this.cbBookRef.TabIndex = 5;
            this.cbBookRef.Text = "Book Ref";
            // 
            // cbSongNumber
            // 
            this.cbSongNumber.AutoSize = true;
            this.cbSongNumber.Location = new System.Drawing.Point(8, 50);
            this.cbSongNumber.Name = "cbSongNumber";
            this.cbSongNumber.Size = new System.Drawing.Size(71, 17);
            this.cbSongNumber.TabIndex = 2;
            this.cbSongNumber.Text = "Song No.";
            // 
            // cbContents
            // 
            this.cbContents.AutoSize = true;
            this.cbContents.Location = new System.Drawing.Point(8, 33);
            this.cbContents.Name = "cbContents";
            this.cbContents.Size = new System.Drawing.Size(68, 17);
            this.cbContents.TabIndex = 1;
            this.cbContents.Text = "Contents";
            // 
            // cbTitle
            // 
            this.cbTitle.AutoSize = true;
            this.cbTitle.Location = new System.Drawing.Point(8, 16);
            this.cbTitle.Name = "cbTitle";
            this.cbTitle.Size = new System.Drawing.Size(46, 17);
            this.cbTitle.TabIndex = 0;
            this.cbTitle.Text = "Title";
            // 
            // FolderList
            // 
            this.FolderList.CheckOnClick = true;
            this.FolderList.FormattingEnabled = true;
            this.FolderList.Location = new System.Drawing.Point(7, 54);
            this.FolderList.Name = "FolderList";
            this.FolderList.Size = new System.Drawing.Size(112, 169);
            this.FolderList.TabIndex = 1;
            // 
            // txtName
            // 
            this.txtName.Location = new System.Drawing.Point(7, 28);
            this.txtName.Name = "txtName";
            this.txtName.Size = new System.Drawing.Size(369, 20);
            this.txtName.TabIndex = 1;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(9, 12);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(105, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Enter search phrase:";
            // 
            // cbUseDates
            // 
            this.cbUseDates.AutoSize = true;
            this.cbUseDates.Location = new System.Drawing.Point(224, 148);
            this.cbUseDates.Name = "cbUseDates";
            this.cbUseDates.Size = new System.Drawing.Size(104, 17);
            this.cbUseDates.TabIndex = 4;
            this.cbUseDates.Text = "Search between";
            this.cbUseDates.CheckedChanged += new System.EventHandler(this.cbUseDates_CheckedChanged);
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(221, 186);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(25, 13);
            this.label6.TabIndex = 6;
            this.label6.Text = "and";
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.Add(this.MatchPhrase);
            this.tabPage2.Controls.Add(this.MatchAny);
            this.tabPage2.Controls.Add(this.MatchAll);
            this.tabPage2.Controls.Add(this.BookLookup);
            this.tabPage2.Controls.Add(this.BibleLookup);
            this.tabPage2.Controls.Add(this.PassageSearchBox);
            this.tabPage2.Controls.Add(this.label3);
            this.tabPage2.Controls.Add(this.label4);
            this.tabPage2.Controls.Add(this.label2);
            this.tabPage2.Location = new System.Drawing.Point(4, 22);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage2.Size = new System.Drawing.Size(382, 230);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "Bible Search";
            // 
            // MatchPhrase
            // 
            this.MatchPhrase.AutoSize = true;
            this.MatchPhrase.Location = new System.Drawing.Point(16, 170);
            this.MatchPhrase.Name = "MatchPhrase";
            this.MatchPhrase.Size = new System.Drawing.Size(144, 17);
            this.MatchPhrase.TabIndex = 5;
            this.MatchPhrase.Text = "Match the phrase exactly";
            // 
            // MatchAny
            // 
            this.MatchAny.AutoSize = true;
            this.MatchAny.Location = new System.Drawing.Point(16, 153);
            this.MatchAny.Name = "MatchAny";
            this.MatchAny.Size = new System.Drawing.Size(136, 17);
            this.MatchAny.TabIndex = 4;
            this.MatchAny.Text = "Match any of the words";
            // 
            // MatchAll
            // 
            this.MatchAll.AutoSize = true;
            this.MatchAll.Checked = true;
            this.MatchAll.Location = new System.Drawing.Point(16, 136);
            this.MatchAll.Name = "MatchAll";
            this.MatchAll.Size = new System.Drawing.Size(117, 17);
            this.MatchAll.TabIndex = 3;
            this.MatchAll.TabStop = true;
            this.MatchAll.Text = "Match all the words";
            // 
            // BookLookup
            // 
            this.BookLookup.FormattingEnabled = true;
            this.BookLookup.Location = new System.Drawing.Point(7, 68);
            this.BookLookup.Name = "BookLookup";
            this.BookLookup.Size = new System.Drawing.Size(178, 21);
            this.BookLookup.TabIndex = 1;
            // 
            // BibleLookup
            // 
            this.BibleLookup.FormattingEnabled = true;
            this.BibleLookup.Location = new System.Drawing.Point(7, 28);
            this.BibleLookup.Name = "BibleLookup";
            this.BibleLookup.Size = new System.Drawing.Size(262, 21);
            this.BibleLookup.TabIndex = 0;
            this.BibleLookup.SelectedIndexChanged += new System.EventHandler(this.BibleLookup_SelectedIndexChanged);
            // 
            // PassageSearchBox
            // 
            this.PassageSearchBox.Location = new System.Drawing.Point(7, 109);
            this.PassageSearchBox.Name = "PassageSearchBox";
            this.PassageSearchBox.Size = new System.Drawing.Size(359, 20);
            this.PassageSearchBox.TabIndex = 2;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(9, 12);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(71, 13);
            this.label3.TabIndex = 5;
            this.label3.Text = "Bible Version:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(9, 52);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(35, 13);
            this.label4.TabIndex = 7;
            this.label4.Text = "Book:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(9, 93);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(105, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Enter search phrase:";
            // 
            // BtnCancel
            // 
            this.BtnCancel.Location = new System.Drawing.Point(217, 276);
            this.BtnCancel.Name = "BtnCancel";
            this.BtnCancel.Size = new System.Drawing.Size(80, 24);
            this.BtnCancel.TabIndex = 1;
            this.BtnCancel.Text = "Close";
            this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
            // 
            // BtnOK
            // 
            this.BtnOK.Location = new System.Drawing.Point(131, 276);
            this.BtnOK.Name = "BtnOK";
            this.BtnOK.Size = new System.Drawing.Size(80, 24);
            this.BtnOK.TabIndex = 0;
            this.BtnOK.Text = "Search";
            this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
            // 
            // TimerRestoreWindow
            // 
            this.TimerRestoreWindow.Tick += new System.EventHandler(this.TimerRestoreWindow_Tick);
            // 
            // FrmFind
            // 
            this.AcceptButton = this.BtnOK;
            this.ClientSize = new System.Drawing.Size(414, 312);
            this.Controls.Add(this.BtnCancel);
            this.Controls.Add(this.BtnOK);
            this.Controls.Add(this.TabControl1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.KeyPreview = true;
            this.MaximizeBox = false;
            this.Name = "FrmFind";
            this.ShowIcon = false;
            this.Text = "Search for EasiSlides Items";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmFind_FormClosing);
            this.Load += new System.EventHandler(this.FrmFind_Load);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FrmFind_KeyDown);
            this.TabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.tabPage1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.tabPage2.ResumeLayout(false);
            this.tabPage2.PerformLayout();
            this.ResumeLayout(false);

		}
        protected override void OnShown(EventArgs e)
        {
            txtName.Focus();
            base.OnShown(e);
        }
		public FrmFind()
		{
			this.InitializeComponent();
		}
		private void FrmFind_Load(object sender, EventArgs e)
		{
			gf.FindItemsFormOpen = true;
			int num = gf.GetRegValue("settings", this.Reg_FormLeft, 50);
			int num2 = gf.GetRegValue("settings", this.Reg_FormTop, 100);
			if (num < 0)
			{
				num = 0;
			}
			else
			{
				if (num > Screen.PrimaryScreen.Bounds.Width - base.Width)
				{
					num = Screen.PrimaryScreen.Bounds.Width - base.Width;
				}
			}
			if (num2 < 0)
			{
				num2 = 0;
			}
			else
			{
				if (num2 > Screen.PrimaryScreen.Bounds.Height - base.Height)
				{
					num2 = Screen.PrimaryScreen.Bounds.Height - base.Height;
				}
			}
			base.Top = num2;
			base.Left = num;
			this.FolderList.Items.Clear();
			for (int i = 1; i < 41; i++)
			{
				if (gf.FolderName[i].ToString() != "" & gf.FolderUse[i] > 0)
				{
					this.FolderList.Items.Add(gf.FolderName[i]);
					if (gf.FindSongsFolder[gf.GetFolderNumber(gf.FolderName[i])])
					{
						this.FolderList.SetItemChecked(this.FolderList.Items.Count - 1, true);
					}
				}
			}
			gf.Find_SQLString = "";
			this.txtName.Text = gf.FindSearchPhrase;
			this.cbTitle.Checked = gf.FindItemInTitle;
			this.cbContents.Checked = gf.FindItemInContents;
			this.cbSongNumber.Checked = gf.FindItemInSongNumber;
			this.cbBookRef.Checked = gf.FindItemInBookRef;
			this.cbUserRef.Checked = gf.FindItemInUserRef;
			this.cbLicAdmin.Checked = gf.FindItemInLicAdmin;
			this.cbWriter.Checked = gf.FindItemInWriter;
			this.cbCopyright.Checked = gf.FindItemInCopyright;
			this.cbMusicOnly.Checked = gf.FindItemMediaOnly;
			this.cbNotationsOnly.Checked = gf.FindItemNotationsOnly;
			this.cbUseDates.Checked = gf.FindItemUseDates;
			this.CalendarFrom.Value = gf.FindItemDateFrom;
			this.CalendarTo.Value = gf.FindItemDateTo;
			this.cbUseDatesChanged();
			this.PopulateKeyTiming();
			this.TimerRestoreWindow.Start();
			this.BibleLookup.Items.Clear();
			this.BookLookup.Items.Clear();            
			if (gf.HB_TotalVersions < 1)
			{
				this.TabControl1.TabPages[1].Enabled = false;
				this.TabControl1.SelectedIndex = 0;
				this.txtName.Focus();
                this.txtName.SelectAll();
			}
			else
			{
				this.TabControl1.TabPages[1].Enabled = true;
				gf.HB_SQLString = "";
				this.PassageSearchBox.Text = gf.FindBibleSearchPhrase;
				this.InitFormLoad = true;
				for (int i = 0; i <= gf.HB_TotalVersions - 1; i++)
				{
					this.BibleLookup.Items.Add(gf.HB_Versions[i, 1] + " - " + gf.HB_Versions[i, 2]);
				}
				this.InitFormLoad = false;
				this.BibleLookup.SelectedIndex = gf.HB_CurVersionTabIndex;
				this.BookLookup.SelectedIndex = gf.FindBibleBookIndex;
				if (gf.FindBibleVerses)
				{
					this.TabControl1.SelectedIndex = 1;
					this.PassageSearchBox.Focus();
					this.PassageSearchBox.SelectAll();
				}
				else
				{
					this.txtName.Focus();
					this.txtName.SelectAll();
				}
			}
		}
		private void OldPopulateSongKeyComboBox()
		{
			this.SongKey.Items.Clear();
			this.SongKey.Items.Add("");
			this.SongKey.Items.Add("A");
			this.SongKey.Items.Add("B");
			this.SongKey.Items.Add("C");
			this.SongKey.Items.Add("D");
			this.SongKey.Items.Add("E");
			this.SongKey.Items.Add("F");
			this.SongKey.Items.Add("G");
			this.SongKey.Items.Add("Am");
			this.SongKey.Items.Add("Bm");
			this.SongKey.Items.Add("Cm");
			this.SongKey.Items.Add("Dm");
			this.SongKey.Items.Add("Em");
			this.SongKey.Items.Add("Fm");
			this.SongKey.Items.Add("Gm");
			this.SongKey.Items.Add("Ab");
			this.SongKey.Items.Add("Bb");
			this.SongKey.Items.Add("Db");
			this.SongKey.Items.Add("Eb");
			this.SongKey.Items.Add("Gb");
			this.SongKey.Items.Add("Abm");
			this.SongKey.Items.Add("Bbm");
			this.SongKey.Items.Add("Dbm");
			this.SongKey.Items.Add("Ebm");
			this.SongKey.Items.Add("Gbm");
			this.SongKey.Items.Add("F#");
			this.SongKey.Items.Add("F#m");
			this.SongKey.Text = gf.FindItemWithKey;
		}
		private void PopulateKeyTiming()
		{
			this.SongKey.Items.Clear();
			this.SongKey.Items.Add("");
			string fullSearchString = "select DISTINCT Key FROM SONG ORDER BY Key";
			Recordset recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF)
				{
					string text = gf.Trim(gf.GetDataString(recordSet, "Key"));
					if (text != "")
					{
						this.SongKey.Items.Add(text);
					}
					recordSet.MoveNext();
				}
			}
			this.SongKey.Text = gf.FindItemWithKey;
			this.SongTiming.Items.Clear();
			this.SongTiming.Items.Add("");
			fullSearchString = "select DISTINCT Timing FROM SONG ORDER BY Timing";
			recordSet = gf.GetRecordSet(gf.ConnectStringMainDB, fullSearchString);
			if (recordSet != null && !recordSet.EOF)
			{
				recordSet.MoveFirst();
				while (!recordSet.EOF)
				{
					string text = gf.Trim(gf.GetDataString(recordSet, "Timing"));
					if (text != "")
					{
						this.SongTiming.Items.Add(text);
					}
					recordSet.MoveNext();
				}
			}
			this.SongTiming.Text = gf.FindItemWithTiming;
		}
		private void BibleLookup_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.InitFormLoad)
			{
				this.BibleLookupIndexChanged();
			}
		}
		private void BibleLookupIndexChanged()
		{
			if (this.BibleLookup.Items.Count >= 1)
			{
				gf.LoadBibleBooksList(this.BibleLookup.SelectedIndex, ref this.BookLookup, true, false);
			}
		}
		private void SaveFormLocation()
		{
			gf.SaveRegValue("settings", this.Reg_FormLeft, base.Left);
			gf.SaveRegValue("settings", this.Reg_FormTop, base.Top);
		}
		private void FrmFind_FormClosing(object sender, FormClosingEventArgs e)
		{
			this.SaveFormLocation();
			this.TimerRestoreWindow.Stop();
			gf.FindItemsFormOpen = false;
		}
		private void TimerRestoreWindow_Tick(object sender, EventArgs e)
		{
			if (gf.FindItemRestoreWindow)
			{
				gf.FindItemRestoreWindow = false;
				if (base.WindowState == FormWindowState.Minimized)
				{
					base.WindowState = FormWindowState.Normal;
				}
				else
				{
					base.Focus();
				}
				base.TopMost = true;
				base.TopMost = false;
			}
		}
		private void BtnOK_Click(object sender, EventArgs e)
		{
			if (this.TabControl1.SelectedIndex == 0)
			{
				if (this.FolderList.CheckedItems.Count == 0)
				{
					base.TopMost = false;
					MessageBox.Show("You have not selected any folders to search!");
					base.TopMost = true;
				}
				else
				{
					this.txtName.Text = gf.Trim(this.txtName.Text);
					gf.FindSearchPhrase = this.txtName.Text;
					gf.FindItemInTitle = this.cbTitle.Checked;
					gf.FindItemInContents = this.cbContents.Checked;
					gf.FindItemInSongNumber = this.cbSongNumber.Checked;
					gf.FindItemInBookRef = this.cbBookRef.Checked;
					gf.FindItemInUserRef = this.cbUserRef.Checked;
					gf.FindItemInLicAdmin = this.cbLicAdmin.Checked;
					gf.FindItemInWriter = this.cbWriter.Checked;
					gf.FindItemInCopyright = this.cbCopyright.Checked;
					gf.FindItemMediaOnly = this.cbMusicOnly.Checked;
					gf.FindItemNotationsOnly = this.cbNotationsOnly.Checked;
					gf.FindItemWithKey = this.SongKey.Text;
					gf.FindItemWithTiming = this.SongTiming.Text;
					gf.FindItemUseDates = this.cbUseDates.Checked;
					gf.FindItemDateFrom = this.CalendarFrom.Value;
					gf.FindItemDateTo = this.CalendarTo.Value;
					gf.Find_SQLString = gf.BuildItemSearchString(this.txtName.Text, gf.FindItemInTitle, gf.FindItemInContents, gf.FindItemInSongNumber, gf.FindItemInBookRef, gf.FindItemInUserRef, gf.FindItemInLicAdmin, gf.FindItemInWriter, gf.FindItemInCopyright, gf.FindItemNotationsOnly, gf.FindItemWithKey, gf.FindItemWithTiming, gf.FindItemUseDates, gf.FindItemDateFrom, gf.FindItemDateTo, this.FolderList);
					if (gf.Find_SQLString != "")
					{
						gf.FindFolderItems = true;
						gf.FindItemsRequested = true;
					}
				}
			}
			else
			{
				if (this.TabControl1.SelectedIndex == 1)
				{
					if (gf.HB_TotalVersions >= 1)
					{
						int matchSelected;
						if (this.MatchAny.Checked)
						{
							matchSelected = 1;
						}
						else
						{
							if (this.MatchAll.Checked)
							{
								matchSelected = 0;
							}
							else
							{
								matchSelected = 2;
							}
						}
						string text = gf.BuildBibleSearchString(this.PassageSearchBox.Text, this.BibleLookup.SelectedIndex, this.BookLookup.SelectedIndex, matchSelected);
						if (text != "")
						{
							gf.HB_CurVersionTabIndex = this.BibleLookup.SelectedIndex;
							gf.HB_SQLString = text;
							gf.FindBibleSearchPhrase = this.PassageSearchBox.Text;
							gf.FindBibleBookIndex = this.BookLookup.SelectedIndex;
							gf.FindItemsRequested = true;
						}
					}
				}
			}
		}
		private void BtnCancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void cbUseDates_CheckedChanged(object sender, EventArgs e)
		{
			this.cbUseDatesChanged();
		}
		private void cbUseDatesChanged()
		{
			this.CalendarFrom.Enabled = this.cbUseDates.Checked;
			this.CalendarTo.Enabled = this.cbUseDates.Checked;
		}

        private void FrmFind_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Escape)
            {
                base.Close();
            }
        }
	}
}
